package com.yonyougov.devops.cruxcisupport.k8s.deployment;

import com.yonyougov.devops.cruxcisupport.k8s.error.K8sConfIgNotFindException;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.client.KubernetesClient;

/**
 * 操作K8S Deployment
 */
public interface DeploymentRepository {
    /**
     * 创建
     * @param deploymentRequest 需要的参数
     * @return Deployment
     */
    Deployment createOrReplace(DeploymentRequest deploymentRequest) throws K8sConfIgNotFindException;


    /**
     * 滚动升级
     * @param deploymentRequest 需要的参数
     * @return Deployment
     */
    Deployment rollingUpgrade(DeploymentRequest deploymentRequest) throws K8sConfIgNotFindException;

    /**
     * 获取某个命名空间下某个应用的Deployment信息
     * @param nameSpace 命名空间
     * @param appName  应用名称
     * @return Deployment 组件
     * @throws K8sConfIgNotFindException
     */
    Deployment get(String nameSpace, String appName) throws K8sConfIgNotFindException;

    /**
     * 获取某个命名空间下某个应用的Deployment信息
     * @param client 客户端
     * @param nameSpace 命名空间
     * @param appName 应用名称
     * @return Deployment 组件
     */
    Deployment get(KubernetesClient client,String nameSpace, String appName);

    /**
     * 删除某个命名空间下某个应用的Deployment信息
     * @param nameSpace 命名空间
     * @param appName  应用名称
     * @throws K8sConfIgNotFindException
     */
     void delete(String nameSpace, String appName) throws K8sConfIgNotFindException;

    /**
     * 获取某个命名空间下某个应用的Deployment信息
     * @param client 客户端
     * @param nameSpace 命名空间
     * @param appName 应用名称
     */
    void delete(KubernetesClient client,String nameSpace, String appName);
}
